package com.chuanjiabao.wisdom.util.dialog;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.view.LayoutInflater;
import android.view.View;

import com.chuanjiabao.wisdom.R;
import com.chuanjiabao.wisdom.databinding.DialogTakeInInviteBinding;
import com.chuanjiabao.wisdom.listener.OnBHClickListener;
import com.flyco.animation.SlideEnter.SlideTopEnter;
import com.flyco.animation.SlideExit.SlideBottomExit;
import com.flyco.dialog.widget.base.BaseDialog;

public class TakeInInviteDialog extends BaseDialog {

    private Context context;
    private String name;
    private DialogTakeInInviteBinding inComminBinding;
    private OnBHClickListener onBHClickListener;

    public TakeInInviteDialog(Context context) {
        super(context);
        this.context = context;
    }

    public TakeInInviteDialog(Context context, String name) {
        super(context);
        this.context = context;
        this.name = name;
    }

    @Override
    public View onCreateView() {
        widthScale(0.8f);
        inComminBinding = DataBindingUtil.inflate(
                LayoutInflater.from(context),
                R.layout.dialog_take_in_invite,
                null,
                false
        );
        inComminBinding.setDialog(this);
        if (name != null) {
            inComminBinding.tvDialogName.setText(name);
        }
        return inComminBinding.getRoot();
    }

    @Override
    public void setUiBeforShow() {
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        showAnim(new SlideTopEnter());
        dismissAnim(new SlideBottomExit());
    }

    public void setOnBHClickListener(OnBHClickListener onBHClickListener) {
        this.onBHClickListener = onBHClickListener;
    }

    public void okPoint(View view) {
        if (onBHClickListener != null) {
            onBHClickListener.onConfirmClick();
        }
        dismiss();
    }
}


